package org.dromara.common.outsys.mairui.service.impl;

import cn.hutool.http.HttpUtil;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import org.dromara.common.outsys.mairui.constant.MairuiConstant;
import org.dromara.common.outsys.mairui.domain.MairuiComBase;
import org.dromara.common.outsys.mairui.service.IMairuiService;
import org.springframework.stereotype.Service;

/**
 * @Description: 基金经理
 * @Author: jeecg-boot
 * @Date:   2022-08-20
 * @Version: V1.0
 */
@Service
public class MairuiServiceImpl implements IMairuiService {

    private static Log logger = LogFactory.get();

    /**
     * 获取基金基础信息
     * @param code
     * @return
     */
    public MairuiComBase getComBaseInfo(String code){


        String url = MairuiConstant.URL_COM_BASE_INFO+"/"+code+"/"+ MairuiConstant.TOKEN;


        String resStr  = HttpUtil.get(url);

        logger.info(resStr);

        JSONObject resParams = JSONObject.parseObject(resStr);

        if (resParams !=null && resParams.getString("Message") !=null){

            MairuiComBase comBase = JSON.toJavaObject(resParams, MairuiComBase.class);
            return comBase;
        }else {
            return null;
        }
    }





}
